fun main() {

    //默认不为空，？可以为空
    var str:String? = "butterfly"
//    str = null //只有？才能赋值空
    //？安全调用操作符，如果null，跳过函数调用
    println(str?.capitalize())
    str = str?.let {
        //非空白的字符串
        if(it.isNotBlank()){
            it.capitalize()
        }else{
            "butterfly"
        }
    }

    //str = null
    //println(str!!.capitalize())

    if(str != null){
        str = str.capitalize()
    }else{
        println("为null.")
    }

    str = str?.capitalize()?.plus(" is great.")

    str = "rose"
    //？：空合并操作符，左边为空使用右边的值
    println(str ?: "jack")

    str = null
    str = str?.let{ it.capitalize() } ?: "butterfly"
    println(str)
}